package com.atguigu.day04.HomeWork;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/3 16:33
 * @注释 打印三种数字三角形
 */
public class HomeWork2 {
    public static void main(String[] args) {
        //第一种三角形
        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(j);
            }
            System.out.println();
        }

        //第二种三角形
        for (int i = 1; i <= 5; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(i);
            }
            System.out.println();
        }

        //第三种三角型
        //方法一
        /*int n = 0;
        for (int i = 1; i <= 5; i++) {
            switch (i) {
                case 1:
                    System.out.print(" ");
                case 2:
                    System.out.print(" ");
                case 3:
                    System.out.print(" ");
                case 4:
                    System.out.print(" ");
            }
            for (int j = 1; j <= (i + n); j++) {
                System.out.print(i);
            }
            n++;
            System.out.println();
        }*/
        //方法二
        for (int i = 1; i <= 5; i++) {
            for (int k = 4; k >= i; k--){
                System.out.print(" ");
            }
            for (int j = 1; (j <= i * 2 - 1); j++) {
                System.out.print(i);
            }
            System.out.println();
        }
    }
}
